package com.ycr.springmvc.event;

import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;

public class MethodExecutionEventPublisher implements ApplicationEventPublisherAware{

	private ApplicationEventPublisher eventPublisher;
	
	@Override
	public void setApplicationEventPublisher(
			ApplicationEventPublisher applicationEventPublisher) {
		this.eventPublisher = applicationEventPublisher;
	}
	
	public void methodToMonitor() {  
        MethodExecutionEvent beginEvent = new MethodExecutionEvent(this, "methodToMonitor", "begin");  
        this.eventPublisher.publishEvent(beginEvent);  
        //TODO  
        MethodExecutionEvent endEvent = new MethodExecutionEvent(this, "methodToMonitor", "end");  
        this.eventPublisher.publishEvent(endEvent);  
    }  

}
